<template>
  <div class="imp w-full bg-white px-5 py-3 box-border overflow-hidden">
    <span class="title">诊断</span>
    <el-input
      v-model="data.diagnosis"
      :rows="2"
      type="textarea"
      placeholder="请填写诊断详情，最多不超多100字。"
      class="mt-2"
    />
    <div class="float-right mt-4">
      <el-button>重置</el-button>
      <el-button type="primary" @click="handlevisitt">确定</el-button>
    </div>
  </div>
</template>

<script setup lang="ts">
import {visitt} from '@/api/patient'
import {ref} from 'vue'
import {storeToRefs} from 'pinia'
import {usePatientStore} from '@/store/modules/patient'
import {ElMessage} from 'element-plus'

const {currentPatient} = storeToRefs(usePatientStore())

const data = ref({
  visitNo: '',
  diagnosis: ''
})

const handlevisitt = () => {
  data.value.visitNo = currentPatient.value.visitNoStr as string
  if (currentPatient.value.visitNoStr) {
    if (data.value.diagnosis.length <= 0) {
      ElMessage.error('请填写诊断！')
    } else {
      visitt(data.value).then((res) => {
        ElMessage.success('诊断成功！')
        data.value.diagnosis = ''
      })
    }
  }
}
</script>

<style scoped lang="less">
.imp {
  .title {
    color: var(--el-text-color-primary);
    font-size: 16px;
    font-weight: 700;
  }
}
</style>
<style lang="less">
.imp {
  .el-textarea__inner {
    background-color: #f2f3f5;
  }
}
</style>
